package com.copa.l191;

/**
 * @author copa
 * @createDate 2022-08-26 10:12
 * @function 位运算
 */
public class Test2 {

    public int hammingWeight(int n) {
        int count = 0;
        while (n != 0) {
            n = n & n - 1;
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
        int n = 00000000000000000000000000001011;
        System.out.println(new Test2().hammingWeight(n));
    }
}
